<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px">
		    <el-form-item label="内容">
				<div>
					<div class="flex" v-for="(el,i) in form.content">
						<div class="flex" style="width: 300px;">
							<div style="margin-right: 10px;">
								精度
							</div>
							<el-input size="mini"
								placeholder="点击地图获取"
								style="width: 260px;"
								v-model="el.lng"></el-input>
						</div>
						<div class="flex" style="width: 300px;">
							<div style="margin-right: 10px;">
								维度
							</div>
							<el-input size="mini"
								placeholder="点击地图获取"
								style="width:260px;"
								v-model="el.lat"></el-input>
						</div>
						
						
					</div>
				</div>
			</el-form-item>
			<el-form-item label="地图">
			  <div>
				  <div id="mapContainer" style="width: 600px; height: 200px;"></div>
			  </div>
			</el-form-item>
			<el-form-item label="状态">
			  <el-radio-group ref="radio" v-model="form.status">
				<el-radio label="0">禁用</el-radio>
				<el-radio label="1">启用</el-radio>
			  </el-radio-group>
			</el-form-item>
			<el-form-item label="排序">
				<el-input size="mini"
					type="number"
					v-model="form.sort"></el-input>
			</el-form-item>
			<el-form-item >
			  <el-button type="primary" @click="confirm" size="small">确定</el-button>
		    </el-form-item>
		</el-form>
		
		
	</div>
</template>

<script>
	
	export default {
		components:{
		},
		props:{
			formDD:{
				type:Object,
				default:{}
			}
		},
		mounted() {
			// 获取到带有aria-hidden属性的元素
			  const ariaEls = this.$refs.radio.$el.querySelectorAll('input[type="radio"]')
			  if (!ariaEls) return
			  ariaEls.forEach((item) => {
			    // aria-hidden属性
			    item.removeAttribute('aria-hidden');
			  });
			setTimeout(()=>{
				if(this.formDD.content){
					this.form.content = JSON.parse(this.formDD.content)
				}
				this.form.status = this.formDD.status
				this.form.sort = this.formDD.sort
				
				var map = new qq.maps.Map(document.getElementById('mapContainer'), {
				    center: new qq.maps.LatLng(this.form.content[0].lat, this.form.content[0].lng), // 设置地图初始中心点
				    zoom: 12                                                 // 初始缩放比例
				});
				
				let _this = this
				
				qq.maps.event.addListener(map, 'click', function(event) {
				    var latLng = event.latLng;
					_this.form.content[0].lat = latLng.getLat()
					_this.form.content[0].lng = latLng.getLng()
					console.log(_this.form.content)
				});
				
				
			},100)
			
			
			
			
			
		},
		data(){
			return {
				isShow:false,
				form:{
					content:[
						{
							lat:'34.71553223774409',
							lng:"113.6429214477539",
							
						}
					],
					status:'1',
					sort:1
				}
			}
		},
		methods:{
			confirm(){
				let params = {
					content:JSON.stringify(this.form.content),
					status:this.form.status,
					sort:this.form.sort,
					cid:sessionStorage.getItem('cid')
				}
				this.$emit('getFormVal',params)
			},
		}
	}
</script>

<style>
	
</style>